package com.gopher.gauth.model;

import java.util.List;

public class ResponseData {

    private static final Integer CODE_SUCCESS=0;
    private static final Integer CODE_FAIL=1;
    //返回码 0 成功 1 失败
    private Integer code;

    private String message;

    private Object data;

    private List<?> list;

    public ResponseData(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public ResponseData(Integer code, String message, Object data, List<?> list) {
        this(code,message);
        this.data = data;
        this.list = list;
    }

    public static ResponseData sucess(){
        return new ResponseData(CODE_SUCCESS,null);
    }
    public static  ResponseData sucess(String message){
        return new ResponseData(CODE_SUCCESS,message);
    }

    public static  ResponseData sucess(Object data){
        ResponseData responseData;
        if (data instanceof List){
            return new ResponseData(CODE_SUCCESS,null,null,(List<?>) data);
        }
        return new ResponseData(CODE_SUCCESS,null,data,null);
    }

    public static  ResponseData sucess(String message,Object data,List<?> list){
        return new ResponseData(CODE_SUCCESS,message,data,list);
    }

    public static  ResponseData error(String message){
        return new ResponseData(CODE_FAIL,message);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public List<?> getList() {
        return list;
    }

    public void setList(List<?> list) {
        this.list = list;
    }
}
